import {
  Controller,
  Post,
  Get,
  Param,
  Delete,
  UploadedFile,
  UseInterceptors,
  Res,
} from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import { ComLocalUploadService } from './com-local-upload.service';
import { FileResponseDto } from './dto/file-response.dto';
import { JwtNoVerify } from '../../decorators';

@Controller('upload-local')
export class ComLocalUploadController {
  constructor(private readonly _uploadService: ComLocalUploadService) {}

  // 上传单个文件  -  直接上传至本地
  @Post('single')
  @UseInterceptors(
    FileInterceptor('file', ComLocalUploadService.prototype.getMulterConfig()),
  )
  async uploadSingleFile(
    @UploadedFile() file: Express.Multer.File,
  ): Promise<FileResponseDto> {
    return await this._uploadService.saveFile(file);
  }
}
